Skip to content

Avoid indenting HTML lists in Markdown Javadoc. - #1545

Merged
copybara-service[bot] merged 1 commit into
masterfrom
test_1028886735
Nov 26, 2026
Merged

copybara-service[bot] merged 1 commit into
masterfrom
test_1028886735

Conversation

@copybara-service

Copy link
Copy Markdown

Avoid indenting HTML lists in Markdown Javadoc.

In /// Markdown Javadoc comments, HTML list tags (<ul>, <ol>, <dl>, <li>, <dt>, <dd>) do not establish CommonMark container blocks; they start Type 6 HTML blocks that end at the next blank line. Pushing 2-space ListIndent and 4+-space ListItemIndent causes subsequent paragraphs, <p>, or <table> blocks after a blank line to reach 4+ columns of indentation, turning them into CommonMark indented code blocks (which disables inline tags and Markdown links and breaks re-formatting). HTML list tags inside Markdown lists could also interfere with the enclosing Markdown list's indentation stack.

In JavadocWriter, handle HTML list open, close, and item tags in Markdown Javadoc without modifying indentStack or continuingListItemOfInnermostList. Request a newline before HTML list open tags when not already at the start of a line (so <li><ol> and <li><ul> remain on one line while inline lists like Intro <ul><li>a</ul> trailing. split onto separate lines), and request newlines around HTML list close tags and after open tags. Inside block tags (2-space continuation indent), flattening <li> from 4+ spaces to 2 spaces means <li> starts a standard Type 6 HTML block rather than a paragraph continuation line, so Markdown [link] syntax inside HTML list items renders literally (consistent with body text and Markdown list items; {@link ...} still works).

In `///` Markdown Javadoc comments, HTML list tags (`<ul>`, `<ol>`, `<dl>`, `<li>`, `<dt>`, `<dd>`) do not establish CommonMark container blocks; they start Type 6 HTML blocks that end at the next blank line. Pushing 2-space `ListIndent` and 4+-space `ListItemIndent` causes subsequent paragraphs, `<p>`, or `<table>` blocks after a blank line to reach 4+ columns of indentation, turning them into CommonMark indented code blocks (which disables inline tags and Markdown links and breaks re-formatting). HTML list tags inside Markdown lists could also interfere with the enclosing Markdown list's indentation stack.

In `JavadocWriter`, handle HTML list open, close, and item tags in Markdown Javadoc without modifying `indentStack` or `continuingListItemOfInnermostList`. Request a newline before HTML list open tags when not already at the start of a line (so `<li><ol>` and `<li><ul>` remain on one line while inline lists like `Intro <ul><li>a</ul> trailing.` split onto separate lines), and request newlines around HTML list close tags and after open tags. Inside block tags (2-space continuation indent), flattening `<li>` from 4+ spaces to 2 spaces means `<li>` starts a standard Type 6 HTML block rather than a paragraph continuation line, so Markdown `[link]` syntax inside HTML list items renders literally (consistent with body text and Markdown list items; `{@link ...}` still works).

PiperOrigin-RevId: 1030659593
@copybara-service
copybara-service Bot merged commit 09ed9c4 into master Nov 26, 2026
16 checks passed
@copybara-service
copybara-service Bot deleted the test_1028886735 branch November 26, 2026 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant